<?php
/**
 * 描述：会员管理中心欢迎页面。
 */
final class Exec_MC_Welcome extends Exec_MC_Master
{   
    public function Get()
    {
        #定义标量
        $data=array();

        #获取用户名
        $account=new Account(Account::Session('Username'));
        {
            $data['Account']=$account->Username;
            $data['Login_Count']=$account->Data['Login_Count'];
            $data['Datetime']=$account->Data['Datetime'];
            $data['Login_Datetime']=$account->Data['Login_Datetime'];
        }
        $account=NULL;

        #获取VIP/普通会员
        $tmp=DB::PGetRows('select * from account_vip where Account=?',array($data['Account']));
        if($tmp){
            $data['IsVip']='TRUE';
        }
        else{
            $data['IsVip']='FALSE';
        }

        #获取供应信息数量
        $tmp=DB::PGetRows('select count(*) as SupplyCount from supply where Account=?',array($data['Account']));
        if($tmp){
            $data['SupplyCount']=$tmp[0]['SupplyCount'];
        }
        else{
            $data['SupplyCount']='0';
        }

        #获取采购信息数量
        $tmp=DB::PGetRows('select count(*) as ProcurementCount from procurement where Account=?',array($data['Account']));
        if($tmp){
            $data['ProcurementCount']=$tmp[0]['ProcurementCount'];
        }
        else{
            $data['ProcurementCount']='0';
        }

        #获取证书上传数理
        $tmp=DB::PGetRows('select count(*) as LicenceCount from licence where Account=?',array($data['Account']));
        if($tmp){
            $data['LicenceCount']=$tmp[0]['LicenceCount'];
        }
        else{
            $data['LicenceCount']='0';
        }

        #渲染输出
        View::Assign('MC_Welcome',$data);






        #获取设置
        $isSettings=NULL;
        $settings=DB::GetRowByValue('news_subscription','Account',Account::Session('Username'));
        if($settings)
        {
            foreach($settings as $key=>$value)
            {
                if((string)$value=='1'){
                    $isSettings=TRUE;
                    break;
                }
            }
            if($isSettings==NULL){
                $settings=NULL;
            }
        }
        else{
            $isSettings=FALSE;
        }
        View::Assign('MC_Subscription_Settings',$settings);

        #获取数据
        if($settings!=NULL&&$isSettings==TRUE)
        {
            #船舶
            //船舶行情
            if($settings['Shipyard_Conjuncture'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::SHIPYARD_CONJUNCTURE_ID);
                View::Assign('MC_Subscription_ShipyardConjuncture_ClassID',DAO_NewsClass::SHIPYARD_CONJUNCTURE_ID);
                View::Assign('MC_Subscription_ShipyardConjuncture',$data);
            }
            //船厂动态
            if($settings['Shipyard_Trends'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::SHIPYARD_TRENDS_ID);
                View::Assign('MC_Subscription_ShipyardTrends_ClassID',DAO_NewsClass::SHIPYARD_TRENDS_ID);
                View::Assign('MC_Subscription_ShipyardTrends',$data);
            }
            //船厂订单
            if($settings['Shipyard_Ordersheet'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::SHIPYARD_ORDERSHEET_ID);
                View::Assign('MC_Subscription_ShipyardOrdersheet_ClassID',DAO_NewsClass::SHIPYARD_ORDERSHEET_ID);
                View::Assign('MC_Subscription_ShipyardOrdersheet',$data);
            }
            //运行分析
            if($settings['Shipyard_Analysis'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::SHIPYARD_ANALYSIS_ID);
                View::Assign('MC_Subscription_ShipyardAnalysis_ClassID',DAO_NewsClass::SHIPYARD_ANALYSIS_ID);
                View::Assign('MC_Subscription_ShipyardAnalysis',$data);
            }

            #船配
            //船配资讯
            if($settings['Ancillary_News'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::ANCILLARY_NEWS_ID);
                View::Assign('MC_Subscription_AncillaryNews_ClassID',DAO_NewsClass::ANCILLARY_NEWS_ID);
                View::Assign('MC_Subscription_AncillaryNews',$data);
            }
            //船配企业
            if($settings['Ancillary_Company'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::ANCILLARY_COMPANY_ID);
                View::Assign('MC_Subscription_AncillaryCompany_ClassID',DAO_NewsClass::ANCILLARY_COMPANY_ID);
                View::Assign('MC_Subscription_AncillaryCompany',$data);
            }
            //船配订单
            if($settings['Ancillary_Ordersheet'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::ANCILLARY_ORDERSHEET_ID);
                View::Assign('MC_Subscription_AncillaryOrdersheet_ClassID',DAO_NewsClass::ANCILLARY_ORDERSHEET_ID);
                View::Assign('MC_Subscription_AncillaryOrdersheet',$data);
            }
            //钢材行情
            if($settings['Ancillary_Steels'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::ANCILLARY_STEELS_ID);
                View::Assign('MC_Subscription_AncillarySteels_ClassID',DAO_NewsClass::ANCILLARY_STEELS_ID);
                View::Assign('MC_Subscription_AncillarySteels',$data);
            }

            #航运
            //航运市场
            if($settings['Shipping_Market'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::SHIPPING_MARKET_ID);
                View::Assign('MC_Subscription_ShippingMarket_ClassID',DAO_NewsClass::SHIPPING_MARKET_ID);
                View::Assign('MC_Subscription_ShippingMarket',$data);
            }
            //船东动态
            if($settings['Shipping_Trends'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::SHIPPING_TRENDS_ID);
                View::Assign('MC_Subscription_ShippingTrends_ClassID',DAO_NewsClass::SHIPPING_TRENDS_ID);
                View::Assign('MC_Subscription_ShippingTrends',$data);
            }

            #融资
            //海工动态
            if($settings['Maritimeworks_Trends'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::MARITIMEWORKS_TRENDS_ID);
                View::Assign('MC_Subscription_MaritimeworksTrends_ClassID',DAO_NewsClass::MARITIMEWORKS_TRENDS_ID);
                View::Assign('MC_Subscription_MaritimeworksTrends',$data);
            }
            //海工订单
            if($settings['Maritimeworks_Ordersheet'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::MARITIMEWORKS_ORDERSHEET_ID);
                View::Assign('MC_Subscription_MaritimeworksOrdersheet_ClassID',DAO_NewsClass::MARITIMEWORKS_ORDERSHEET_ID);
                View::Assign('MC_Subscription_MaritimeworksOrdersheet',$data);
            }

            #访谈
            $data=DB::GetRows('select * from interview order by ID desc limit 0,5');
            View::Assign('MC_Subscription_Interview',$data);

            #专题
            $data=DB::GetRows('select * from topic order by ID desc limit 0,5');
            View::Assign('MC_Subscription_Topic',$data);

            #观察
            $data=DB::GetRows('select * from news where M_IsDelete=FALSE and SubclassID='.DAO_NewsClass::OBSERVE_COMMENT_ID.' order by ID desc limit 0,5');
            View::Assign('MC_Subscription_Observe',$data);

            #船型
            if($settings['ShipType'])
            {
                $data=DAO_News::Class_Default(DAO_NewsClass::TYPE_ID);
                View::Assign('MC_Subscription_ShipType_ClassID',DAO_NewsClass::TYPE_ID);
                View::Assign('MC_Subscription_ShipType',$data);
            }

            #数据
            //新造船市场
            if($settings['Data_New'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::DATA_NEW_ID);
                View::Assign('MC_Subscription_DataNew_ClassID',DAO_NewsClass::DATA_NEW_ID);
                View::Assign('MC_Subscription_DataNew',$data);
            }
            //二手船市场
            if($settings['Data_Second'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::DATA_SECOND_ID);
                View::Assign('MC_Subscription_DataSecond_ClassID',DAO_NewsClass::DATA_SECOND_ID);
                View::Assign('MC_Subscription_DataSecond',$data);
            }
            //拆船市场
            if($settings['Data_Scrap'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::DATA_SCRAP_ID);
                View::Assign('MC_Subscription_DataScrap_ClassID',DAO_NewsClass::DATA_SCRAP_ID);
                View::Assign('MC_Subscription_DataScrap',$data);
            }
            //船运市场
            if($settings['Data_Shipping'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::DATA_SHIPPING_ID);
                View::Assign('MC_Subscription_DataShipping_ClassID',DAO_NewsClass::DATA_SHIPPING_ID);
                View::Assign('MC_Subscription_DataShipping',$data);
            }
            //钢材市场
            if($settings['Data_Steels'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::DATA_STEELS_ID);
                View::Assign('MC_Subscription_DataSteels_ClassID',DAO_NewsClass::DATA_STEELS_ID);
                View::Assign('MC_Subscription_DataSteels',$data);
            }
            //租船市场
            if($settings['Data_Rent'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::DATA_RENT_ID);
                View::Assign('MC_Subscription_DataRent_ClassID',DAO_NewsClass::DATA_RENT_ID);
                View::Assign('MC_Subscription_DataRent',$data);
            }

            #融资
            //信贷政策
            if($settings['Finacing_Policy'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::FINACING_POLICY_ID);
                View::Assign('MC_Subscription_FinacingPolicy_ClassID',DAO_NewsClass::FINACING_POLICY_ID);
                View::Assign('MC_Subscription_FinacingPolicy',$data);
            }
            //银企合作
            if($settings['Finacing_Cooperation'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::FINACING_COOPERATION_ID);
                View::Assign('MC_Subscription_FinacingCooperation_ClassID',DAO_NewsClass::FINACING_COOPERATION_ID);
                View::Assign('MC_Subscription_FinacingCooperation',$data);
            }
            //融资动态
            if($settings['Finacing_Trends'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::FINACING_TRENDS_ID);
                View::Assign('MC_Subscription_FinacingTrends_ClassID',DAO_NewsClass::FINACING_TRENDS_ID);
                View::Assign('MC_Subscription_FinacingTrends',$data);
            }
            //融资上市
            if($settings['Finacing_IPO'])
            {
                $data=DAO_News::Subclass_Default(DAO_NewsClass::FINACING_IPO_ID);
                View::Assign('MC_Subscription_FinacingIPO_ClassID',DAO_NewsClass::FINACING_IPO_ID);
                View::Assign('MC_Subscription_FinacingIPO',$data);
            }

            #技术、船配标准
            if($settings['Technology'])
            {
                $data=DAO_News::Class_Default(DAO_NewsClass::TECHNOLOGY_ID);
                View::Assign('MC_Subscription_Technology_ClassID',DAO_NewsClass::TECHNOLOGY_ID);
                View::Assign('MC_Subscription_Technology',$data);
            }
            if($settings['Standard'])
            {
                $data=DAO_News::Class_Default(DAO_NewsClass::STANDARD_ID);
                View::Assign('MC_Subscription_Standard_ClassID',DAO_NewsClass::STANDARD_ID);
                View::Assign('MC_Subscription_Standard',$data);
            }

            #政策法规
            if($settings['Law'])
            {
                $data=DAO_News::Class_Default(DAO_NewsClass::LAW_ID);
                View::Assign('MC_Subscription_Law_ClassID',DAO_NewsClass::LAW_ID);
                View::Assign('MC_Subscription_Law',$data);
            }
        }







        $this->MasterPage_Display(View::Fetch('mc/welcome.tpl'));
    }
}
?>